/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uni.j2ee.forum.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ivan
 */
@Entity
@Table(name = "USERS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ForumUser.findAll", query = "SELECT f FROM ForumUser f"),
    @NamedQuery(name = "ForumUser.findByUsername", query = "SELECT f FROM ForumUser f WHERE f.username = :username"),
    @NamedQuery(name = "ForumUser.findByFirstName", query = "SELECT f FROM ForumUser f WHERE f.firstName = :firstName"),
    @NamedQuery(name = "ForumUser.findByLastName", query = "SELECT f FROM ForumUser f WHERE f.lastName = :lastName"),
    @NamedQuery(name = "ForumUser.findByPassword", query = "SELECT f FROM ForumUser f WHERE f.password = :password"),
    @NamedQuery(name = "ForumUser.findByRegDate", query = "SELECT f FROM ForumUser f WHERE f.regDate = :regDate"),
    @NamedQuery(name = "ForumUser.findByRole", query = "SELECT f FROM ForumUser f WHERE f.role = :role")})
public class ForumUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "USERNAME")
    private String username;
    @Size(max = 255)
    @Column(name = "FIRST_NAME")
    private String firstName;
    @Size(max = 255)
    @Column(name = "LAST_NAME")
    private String lastName;
    @Size(max = 255)
    @Column(name = "PASSWORD")
    private String password;
    @Column(name = "REG_DATE")
    @Temporal(TemporalType.DATE)
    private Date regDate;
    @Size(max = 255)
    @Column(name = "ROLE")
    private String role;

    public ForumUser() {
    }

    public ForumUser(String username) {
        this.username = username;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getRegDate() {
        return regDate;
    }

    public void setRegDate(Date regDate) {
        this.regDate = regDate;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ForumUser)) {
            return false;
        }
        ForumUser other = (ForumUser) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "uni.j2ee.forum.model.ForumUser[ username=" + username + " ]";
    }
    
}
